
//super
//只能在非静态中使用
//1.super.data 在子类当中访问父类的成员变量
//2.super.func() 在子类当中 访问父类的成员方法
class Base {
    public int a;
    public int b;
    public int c = 199;

    public void methodBase() {
        System.out.println("Base");
    }
}

class Derived extends Base {

    public void methodBase(int a) {
        System.out.println("Derived");//重载
    }
    public void methodDerived() {
        System.out.println("Derived");
    }
    public int c = 9;

    public void func() {
        System.out.println(super.c);//访问父类的c
        methodBase();
        super.methodBase();//访问父类的methofBase
        methodDerived();
    }
    public void func1() {

        //子类有就拿子类的 子类没有就拿父类的
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);//9  如果父类和子类有同名的成员变量，优先访问子类自己的  就近原则


    }
}
public class Test2 {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.func();
    }
}
